package com.wxs.shiro.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfigurer implements WebMvcConfigurer {
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		// 如下配置则能可以访问src/main/resources/mysource下面的文件
		registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
		// 如访问mysource文件夹下的a.jpg，则输入：localhost:8080/myprofix/a.jpg
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/login").excludePathPatterns("/login/**").excludePathPatterns("/statics/**");
	}
}
